Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-8819: Finish FTDC #4579

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

dgottlieb
Copy link
Member

No description provided.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Nov 21, 2024
// `ftdcDirectory`.
func New(ftdcDirectory string, logger logging.Logger) *FTDC {
ret := newFTDC(logger)
ret.maxFileSizeBytes = 1_000_000
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the settings a more formal division. One either passes in a directory and all these variables about managing files are initialized. Or one passes in a writer and none of those variables matter.

ftdc/ftdc.go Outdated
@@ -536,7 +553,7 @@ func (ftdc *FTDC) checkAndDeleteOldFiles() error {
// deletion testing. Filename generation uses padding such that we can rely on there before 2/4
// digits for every numeric value.
//
//nolint
// nolint
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It joys me that our linter lints our linter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe this was gofmt. The linter complained and it's now back to its unindented state.

ftdc.ftdcDir = ftdcFileDir
// We must not use `NewWithWriter`. Forcing a writer for FTDC data is not compatible with FTDC
// file rotation.
ftdc := New(ftdcFileDir, logger.Sublogger("ftdc"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "refactor" of New vs NewWithWriter resulted in changing the order here. First create the directory, then pass it to the constructor.

@@ -416,7 +416,8 @@ func newWithResources(

var ftdcWorker *ftdc.FTDC
if rOpts.enableFTDC {
ftdcWorker = ftdc.New(logger.Sublogger("ftdc"))
// CloudID is also known as the robot part id.
ftdcWorker = ftdc.New(ftdc.DefaultDirectory(config.ViamDotDir, cfg.Cloud.ID), logger.Sublogger("ftdc"))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically has a bug -- cfg.Cloud.ID is nil for local configs. Fixed in last commit.

@@ -36,6 +39,31 @@ type gnuplotWriter struct {
options graphOptions
}

type KVPair[K, V any] struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect you'll enjoy this @benjirewis

nolintPrintln("Expected an FTDC filename. E.g: go run parser.go <path-to>/viam-server.ftdc")
return
}

data, err := ftdc.Parse(ftdcFile)
logger := logging.NewDebugLogger("parser")
logger.SetLevel(logging.WARN)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with a simple NewLogger and removed the SetLevel -- using the INFO default.

@@ -416,8 +416,12 @@ func newWithResources(

var ftdcWorker *ftdc.FTDC
if rOpts.enableFTDC {
partID := "local-config"
if cfg.Cloud != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug fix

@@ -48,7 +48,7 @@ type Arguments struct {
OutputTelemetry bool `flag:"output-telemetry,usage=print out telemetry data (metrics and spans)"`
DisableMulticastDNS bool `flag:"disable-mdns,usage=disable server discovery through multicast DNS"`
DumpResourcesPath string `flag:"dump-resources,usage=dump all resource registrations as json to the provided file path"`
EnableFTDC bool `flag:"ftdc,usage=enable fulltime data capture for diagnostics [beta feature]"`
EnableFTDC bool `flag:"ftdc,default=true,usage=enable fulltime data capture for diagnostics"`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stole from WebRTC above on line 45. Hand tested that -ftdc=false turns this off.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 21, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 21, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 21, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 21, 2024
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants